package com.small.web;

import java.util.HashMap;
import java.util.Map;

/**
 * Controller返回的视图对象
 * Created by fangzheng on 2018/1/30.
 */
public class View {
    /**
     * 请求的视图路径：/view/user/userlist.jsp
     */
    private String path;
    /**
     * 请求的模型数据：json格式的数据
     */
    private Map<String ,Object> model = new HashMap<String, Object>();

    public View() {
    }

    public View(String path) {
        this.path = path;
    }

    /**
     * 添加视图
     * @param viewPath
     * @return
     */
    public View addView(String viewPath){
        this.path = viewPath;
        return this;
    }
    /**
     * 添加模型数据
     * @param key
     * @param value
     * @return
     */
    public View addModel(String key,Object value){
        model.put(key, value);
        return this;
    }

    public String getPath() {
        return path;
    }

    public Map<String, Object> getModel() {
        return model;
    }
}
